<?php
class Bizprofile_Widgets_Help_Widget extends Tomato_Widget 
{
	protected function _prepareShow() 
	{
		$front = Zend_Controller_Front::getInstance();
		$request = $front->getRequest();
		$params  = $request->getParams();
		$enterprise_id_parner = $request->getparam("enterprise_id",null);
		//print_r($params);
		
        $enterprise_id = 0;
        $user_id = 0;
        $auth = Zend_Auth::getInstance();
        $enterprise = null;
        if ($auth->hasIdentity()) {
            $user = $auth->getIdentity();
            if($user->enterprise){
                $enterprise_id = $user->enterprise->id;
                $user_id = $user->user_id;
                $enterprise = $user->enterprise;
            }
        }
		$this->_view->enterprise = $enterprise;
        $conn = Tomato_Db_Connection::factory()->getMasterConnection();
        $enterpriseDao = Tomato_Model_Dao_Factory::getInstance()->setModule('enterprise')->getEnterpriseDao();
        $enterpriseDao->setDbConnection($conn);
		$enterprise_Parner = null;
		if($enterprise_id_parner)
			$enterprise_Parner = $enterpriseDao->getById($enterprise_id_parner,null); // null <=> deleted != 1
		$showHelp = null;
		// lưu ý tại đây không cần xét deleted do trong hàm getById(..,null) đã có điều kiện <> 1 rồi
		if($enterprise_id_parner){
			if($enterprise_Parner->frontend_active==1 && $enterprise)
				$showHelp = true;
		}
		$this->_view->assign("showHelp",$showHelp);
	}
	
	protected function _prepareConfig()
	{
		
	}
}
